=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 03-09-93 (04:07) Number: 262 From: STEVE SHULTZ Refer#: 230 To: KIRK MESSNER Recvd: NO Subj: Basic Routine Conf: (35) Quick Basi --------------------------------------------------------------------------- KM>Does anyone have a Basic/QuickBasic routine to convert inputted values KM>to word form? KM>EXAMPLE: KM>1,725.15 = One Thousand Seven Hundred Twenty Five & 15/100 My apologies for the length but here is one for writing checks. You can modify it to suit your needs. FUNCTION wordamt$ (amt$) STATIC init AS STRING * 1, units$(), tens$(), digits() AS STRING * 1 IF init <> "Y" THEN DIM units$(0 TO 19) DIM tens$(2 TO 9) DIM digits(6) AS STRING * 1 FOR j% = 0 TO 19 READ units$(j%) NEXT j% FOR j% = 2 TO 9 READ tens$(j%) NEXT j% init = "Y" END IF DATA ZERO,ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN,ELEVEN DATA TWELVE,THIRTEEN,FOURTEEN,FIFTEEN,SIXTEEN,SEVENTEEN,EIGHTEEN,NINETEEN DATA TWENTY,THIRTY,FORTY,FIFTY,SIXTY,SEVENTY,EIGHTY,NINETY prtamt$ = "" IF INSTR(amt$, ".") = 0 THEN cents$ = "NO" dollar$ = LTRIM$(RTRIM$(amt$)) GOTO wordcont END IF cents$ = RTRIM$(MID$(amt$, INSTR(amt$, ".") + 1, LEN(amt$) - INSTR(amt$, "."))) IF VAL(cents$) = 0 THEN cents$ = "NO" IF LEN(cents$) = 1 THEN cents$ = cents$ + "0" dollar$ = LTRIM$(MID$(amt$, 1, INSTR(amt$, ".") - 1)) wordcont: numdigits% = LEN(dollar$) IF numdigits% > 6 THEN wordamt$ = "ERROR" EXIT FUNCTION END IF FOR j% = 1 TO numdigits% digits(j%) = MID$(dollar$, j%, 1) NEXT j% SELECT CASE numdigits% CASE IS = 0 wordamt$ = "NO DOLLARS AND " + cents$ + " CENTS" EXIT FUNCTION CASE IS = 1 work$ = digits(1) GOSUB dounits wordamt$ = prtamt$ + " AND " + cents$ + "/100 DOLLARS" EXIT FUNCTION CASE IS = 2 work$ = digits(1) + digits(2) GOSUB dotens wordamt$ = prtamt$ + " AND " + cents$ + "/100 DOLLARS" EXIT FUNCTION CASE IS = 3 work$ = digits(1) + digits(2) + digits(3) GOSUB dohundreds wordamt$ = prtamt$ + " AND " + cents$ + "/100 DOLLARS" EXIT FUNCTION CASE IS = 4 work$ = digits(1) IF VAL(work$) <> 0 THEN GOSUB dounits prtamt$ = prtamt$ + " THOUSAND " END IF work$ = digits(2) + digits(3) + digits(4) GOSUB dohundreds wordamt$ = prtamt$ + " AND " + cents$ + "/100 DOLLARS" EXIT FUNCTION CASE IS = 5 work$ = digits(1) + digits(2) IF VAL(work$) <> 0 THEN GOSUB dotens prtamt$ = prtamt$ + " THOUSAND " END IF work$ = digits(3) + digits(4) + digits(5) GOSUB dohundreds wordamt$ = prtamt$ + " AND " + cents$ + "/100 DOLLARS" EXIT FUNCTION CASE IS = 6 work$ = digits(1) + digits(2) + digits(3) --- Maximus 2.01wb * Origin: Connect America SuperSystem - 512 459-3351 (1:382/10) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20